﻿Public Class Input_Favourite

    Private Sub Create_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Create.Click

        If URL_of_favourite.Text.Contains("www.") Then ' checks if it a valid website by checking if it has www. in it
            If URL_of_favourite.Text.ToLower.Contains("http://") Then ' checks if it has http:// in it
                My.Settings.FavouritesURL.Add(URL_of_favourite.Text) ' if it does have http:// in it then it adds it to the setting
            ElseIf Not URL_of_favourite.Text.ToLower.Contains("http://") Then ' checks if it has http:// in it
                My.Settings.FavouritesURL.Add("http://" & URL_of_favourite.Text) ' if it doesnt have http:// in it it put it in
            End If
        End If
        My.Settings.FavouriteName.Add(Name_of_favourite.Text) ' adds the name of the favourite to the setting
        MsgBox("Favourite Made")

        Form1.FavouriteShow()
        Me.Close()

    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub Input_Favourite_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.FavouritesURL Is Nothing Then
            My.Settings.FavouritesURL = New System.Collections.Specialized.StringCollection
        End If

        If My.Settings.FavouriteName Is Nothing Then
            My.Settings.FavouriteName = New System.Collections.Specialized.StringCollection
        End If

    End Sub

    Private Sub Current_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Current.Click
        Dim url_name() As String ' will store split parts

        URL_of_favourite.Text = Form1.AddressBar.Text ' copies the current URL to the text box
        url_name = Split(URL_of_favourite.Text, ".") ' splits the URL where the . is
        Name_of_favourite.Text = url_name(1) ' copies the name of the webpage into the textbox
    End Sub
End Class